<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header">
</head>
<link rel="stylesheet" th:href="@{/css/yw.css}">
<body class="hold-transition skin-blue sidebar-mini">
<!--查看回款模态框-->
<div class="modal fade" id="modal-select-money">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查看收款信息</h4>
            </div>
            <div class="modal-body">
                <form id="moneyForm-select" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">款项</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="rmiName" autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">款项比例</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="rmiExpectScale" autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">应收金额</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="singleRmiExpectMoney" autocomplete="off"
                                   readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">已收金额</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="singleAlreadyMoney" autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">未收金额</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="singleReceivableNotReceivedMoney"
                                   autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group" id="yswsDiv-select">
                        <label class="col-sm-3 control-label">应收未收</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="yingshouweishou"
                                   autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">预计回款时间</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="rmiExpectDate"
                                   autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group" id="mzjeDiv-select">
                        <label class="col-sm-3 control-label">抹账金额</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="singleRmiDebtsMoney" autocomplete="off"
                                   placeholder="抹账" readonly>
                        </div>
                    </div>
                    <div class="form-group" id="hzje-select">
                        <label class="col-sm-3 control-label">坏账金额</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="singleRmiBadMoney" autocomplete="off"
                                   placeholder="坏账" readonly>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<!--编辑回款模态框-->
<div class="modal fade" id="modal-edit-money">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改收款信息</h4>
            </div>
            <div class="modal-body">
                <form id="moneyForm-edit" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">款项</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="rmiName" autocomplete="off"
                                   readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">款项比例</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="rmiExpectScale" autocomplete="off"
                                   readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">应收金额</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="singleRmiExpectMoney" autocomplete="off"
                                   readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">已收金额</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="singleAlreadyMoney" autocomplete="off"
                            >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">未收金额</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="singleReceivableNotReceivedMoney"
                                   autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group" id="yswsDiv-edit">
                        <label class="col-sm-3 control-label">应收未收</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="yingshouweishou"
                                   autocomplete="off"
                                   placeholder="" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">预计回款时间</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control datepicker" name="rmiExpectDate"
                                   autocomplete="off"
                            >
                        </div>
                    </div>
                    <div class="form-group" id="mzjeDiv-edit">
                        <label class="col-sm-3 control-label">抹账金额</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="singleRmiDebtsMoney" autocomplete="off"
                            >
                        </div>
                    </div>
                    <div class="form-group" id="hzjeDiv-edit">
                        <label class="col-sm-3 control-label">坏账金额</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="singleRmiBadMoney" autocomplete="off"
                            >
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-success" id="btn-save1" data-dismiss="modal" onclick="saveData1()">
                    <span class="Bold">保存</span>
                </button>
            </div>
        </div>
    </div>
</div>

<!--上传模态框-->
<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-import">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">上传附件</h4>
            </div>
            <div class="modal-body">
                <form id="importForm">
                    <input type="hidden" id="invId" name="invId">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">选择文件并上传</label>
                        <div class="col-sm-8">
                            <input type="hidden" class="form-control" name="" autocomplete="off"
                            >
                        </div>
                        <input id="import-file" class="btn" type="file" name="file">
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">文件备注</label>
                        <div class="col-sm-8">
                        <textarea class="form-control text-left" rows="2" name="remark"
                        >
                        </textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button id="btn-import" type="button" class="btn btn-success" style="margin-top: 20px">
                    <span class="Bold">确定</span>
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal" style="margin-top: 20px">取消</button>
            </div>
        </div>
    </div>
</div>

<!--查看附件模态框-->
<div class="modal fade" id="modal-fujianlist-select">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查看附件清单</h4>
            </div>
            <div class="modal-body">

                <div>
                    <table class="table table-bordered" id="bootstrap-table3" name='bootstrap-table3'></table>
                </div>

            </div>


            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<!--添加发票模态框-->
<div class="modal fade" id="modal-invoice-add">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">添加发票信息</h4>
            </div>
            <div class="modal-body">
                <form id="invoiceForm-add" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">发票号</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="invCode" autocomplete="off"
                            >
                            <input type="hidden" name="invConId" id="invConId">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">货物名称</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" name="invGoodsName" autocomplete="off"
                            >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">税价合计</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" name="invAmount" autocomplete="off"
                            >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">开票日期</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control datepicker" name="invDate"
                                   placeholder="请选择">
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">选择文件并上传</label>
                        <div class="col-sm-8">
                            <input type="hidden" class="form-control" name="" autocomplete="off"
                            >
                        </div>
                        <input id="import-file2" class="btn" type="file" name="file">
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">文件备注</label>
                        <div class="col-sm-8">
                        <textarea class="form-control text-left" rows="2" name="remark"
                        >
                        </textarea>
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-success" id="btn-save3" data-dismiss="modal">
                    <span class="Bold">保存</span>
                </button>
            </div>
        </div>
    </div>
</div>

<section class="content-header">
    <h1 style="display:inline-block">
        项目款票审核
    </h1>
    <button type="button" class="btn btn-primary pull-right" margin-right="30px"
            onclick="javascript:window.history.back();">
            <span class="Bold">返回</span>
        </button>
</section>

<section class="content">
    <div class="well well-lg" style="background-color: #fff;">
        <div class="row">
            <div class="form-inline">
                <div class="form-group">
                    <label>项目编号</label>
                    <input type="text" class="form-control" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE; min-width: 1000px !important;"
                           th:value="${info.contName}">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="form-inline">
                <div class="form-group">
                    <label>包含项目</label>
                    <input type="text" class="form-control" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE; min-width: 1000px !important;"
                           th:value="${info.name}">
                </div>
            </div>
        </div>

        <div class="row">
            <div class="form-inline">
                <div class="form-group">
                    <label>签订日期</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${#dates.format(info.contYear,'yyyy-MM-dd')}">
                </div>

                <div class="form-group">
                    <label>买方</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${info.totalMethod}">
                </div>

                <div class="form-group">
                    <label>买房合同编号</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${info.buyCode}">
                </div>

                <div class="form-group">
                    <label>卖方合同编号</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${info.sellCode}">
                </div>

                <div class="form-group">
                    <label>类别</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${info.contType}">
                </div>

                <div class="form-group">
                    <label>合同金额</label>
                    <input type="text" class="form-control  text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;"
                           th:value="${#numbers.formatDecimal(info.partMoney,1,2)}">
                </div>


                <div class="form-group" style="width: 100px;">
                    <label>数量</label>
                    <input type="text" class="form-control text-center" readonly
                           style="background-color: #fff; border: none; border-bottom: solid 1px #EEEEEE;width: 50px;"
                           th:value="${info.cnt}">
                </div>


                <div th:text="${info.conId}" hidden name="conId" class="conId"></div>

            </div>
        </div>

    </div>
    <div class="row">
        <!--table1窗体-->
        <div class="col-md-6">
            <!--回款table-->
            <div class="box  box-warning">
                <div class="box-header">
                    <h3 class="box-title">回款信息</h3>
                </div>
                <div class="box-body no-padding">
                    <table class="table table-bordered" id="bootstrap-table1"
                           style="max-height: 300px;overflow: auto"></table>
                </div>
            </div>

            <div class="box  box-info" id="zongbao" name="zongbao">
                <div class="box-header">
                    <h3 class="box-title">总包方回款信息</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body no-padding">
                    <table class="table table-bordered" id="bootstrap-table4"></table>
                </div>
            </div>


        </div>


        <div class="col-md-6" style="padding-left:0px;">
            <div class="box box-success">
                <div class="box-header">
                    <h3 class="box-title">发票信息</h3>
                    <button id="addFapiao" onclick="openCreateInvoiceModal()" class="btn btn-success btn-xs pull-right">
                        添加发票
                    </button>
                </div>
                <!-- /.box-header -->
                <div class="box-body no-padding">
                    <table class="table table-bordered" id="bootstrap-table2"></table>
                </div>
            </div>

            <div class="box box-danger" th:if="${not #lists.isEmpty(appList)}">
                <div class="box-header">
                    <h3 class="box-title">审批信息</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body no-padding">
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                            <!--<th style="width: 10px">#</th>-->
                            <th class="text-center">审批人</th>
                            <th class="text-center">审批时间</th>
                            <th class="text-center">审批结果</th>
                            <th class="text-center">审批意见</th>
                        </tr>

                        <tr th:each="appList:${appList}">
                            <!--<td th:text="${appList.id}">1.</td>-->
                            <td th:text="${appList.name}"></td>
                            <td th:text="${appList.appTime}"></td>
                            <td th:text="${appList.projectName}"></td>
                            <td th:text="${appList.remark}"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <form id="approveForm">
                <div class="form-group ">
                    <input name="conId" th:value="${conId}" type="hidden"/>
                    <input name="id" th:value="${processId}" type="hidden"/>
                    <input name="processId" th:value="${processId}" type="hidden"/>
                    <input name="appStatus" type="hidden" id="appStatus"/>
                    <input name="remark" type="hidden" id="appRemark"/>

                </div>
                <button type="button" class="btn btn-danger pull-right" id="btn-ng"
                        style="margin-top: 5px; margin-right: 30px;" onclick="saveApprove2(0)">
                    <span class="Bold" shiro:hasPermission="pay:audit:check">驳回</span>
                </button>

                <button type="button" class="btn btn-success pull-right" id="btn-ok"
                        style="margin-top: 5px;margin-right: 30px;" onclick="saveApprove(2)">
                    <span class="Bold" shiro:hasPermission="pay:audit:check">同意</span>
                </button>
            </form>
        </div>
    </div>

    </div>


    </div>
</section>
<div th:include="include :: footer">
</div>
<script th:inline="javascript">
    var table1, table2, table3;
    var flag = false;
    var timeNow = new Date();
    $("#addFapiao").hide();

    /**
     * 审批通过  2同意
     */
    function saveApprove(appType) {
        $("#appStatus").val(appType);

        js.modal.confirm("确认通过吗？", function () {

            js.submit({
                url: ctx + "invoiceManage/kpAppInfoByUserRole",
                data: new FormData($("#approveForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {

                        //切换回页面
                        location.href = ctx + "invoiceList/listIndex2";
                        js.modal.success(result.msg);

                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        })


    }


    /**
     * 审批  0 驳回
     */
    function saveApprove2(appType) {
        $("#appStatus").val(appType);
        js.modal.prompt("请编辑驳回原因", function (reason) {
            if (reason == null || reason == undefined || reason === "" || reason == "null" || reason == 'undefined') {
                reason = "驳回";
            }
            $("#appRemark").val(reason);
            // 执行审核
            js.submit({
                url: ctx + "invoiceManage/kpAppInfoByUserRole",
                data: new FormData($("#approveForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {

                        //切换回页面
                        location.href = ctx + "invoiceList/listIndex2";
                        js.modal.success(result.msg);

                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        })
    }


    $(function () {

        table1 = js.table.init({
            id: "bootstrap-table1",
            url: ctx + "moneyInfoByConId?conId=" + [[${info.conId}]],
            showColumns: false,
            showExport: false,
            pageSize: 300,
            pagination: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        var pageSize = table1.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table1.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: "款项比例", field: 'rmiExpectScale',
                    formatter: function (value, row, index) {
                        return changeHundred(value, row);
                    }
                },
                {title: "收款项", field: 'rmiName'},
                {title: "应收金额", field: 'singleRmiExpectMoney'},
                {title: "已收金额", field: 'singleAlreadyMoney', visible: true},
                {
                    title: "收款比例", field: 'singleCollectionScale',
                    formatter: function (value, row, index) {
                        return changeHundred(value, row);
                    }
                },
                {title: "抹账金额", field: 'singleRmiDebtsMoney'},
                {title: "坏账金额", field: 'singleRmiBadMoney'},
                {
                    title: "预计回<br>款时间", field: 'rmiExpectDate', visible: true,
                    formatter: function (value, row, index) {
                        return changeDateFormat(value)
                    }
                },
                {
                    title: "应收未收", field: 'singleReceivableNotReceivedMoney',
                    formatter: function (value, row, index) {
                        return timeCompare(value, row);
                    }
                },
                {title: "总包付<br>款比例", field: '', visible: flag},
                {title: "已付金额", field: '', visible: flag},
                {
                    title: "操作", formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openSelectMoneyModal(' + js.jsonStringify(row) + ')"> 查看</a> ');
                        // actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openEditMoneyModal(' + js.jsonStringify(row) + ')"> 编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        });

        if ([[${info.contType}]] != "合作制造") {
            flag = true;
            $("#zongbao").hide();
        }
        table1 = js.table.init({
            id: "bootstrap-table4",
            url: ctx + "ZBmoneyInfoByConId?conId=" + [[${info.conId}]],
            showColumns: false,
            showExport: false,
            pageSize: 300,
            pagination: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        var pageSize = table1.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table1.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: "款项比例", field: 'rmiExpectScale',
                    formatter: function (value, row, index) {
                        return changeHundred(value, row);
                    }
                },
                {title: "收款项", field: 'rmiName'},
                {title: "应收金额", field: 'singleRmiExpectMoney'},
                {title: "已收金额", field: 'singleAlreadyMoney', visible: true},
                {
                    title: "收款比例", field: 'singleCollectionScale',
                    formatter: function (value, row, index) {
                        return changeHundred(value, row);
                    }
                },
                {
                    title: "预计回<br>款时间", field: 'rmiExpectDate', visible: true,
                    formatter: function (value, row, index) {
                        return changeDateFormat(value)
                    }
                },
                {title: "是否为总包", field: 'rmiIsAll', visible: false},
                {title: "已付金额", field: '', visible: flag},
                {
                    title: "操作", formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openSelectMoneyModal(' + js.jsonStringify(row) + ')"> 查看</a> ');
                        // actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openEditMoneyModal(' + js.jsonStringify(row) + ')"> 编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        });

        table2 = js.table.init({
            id: "bootstrap-table2",
            url: ctx + "invInfoByConId?conId=" + [[${info.conId}]],
            showColumns: false,
            showExport: false,
            pageSize: 300,
            pagination: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        var pageSize = table2.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table2.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {title: "发票表主键", field: 'invId', visible: false},
                {title: "发票号", field: 'invCode'},
                {title: "货物名称", field: 'invGoodsName'},
                {title: "价税合计", field: 'invAmount'},
                {
                    title: "开票日期", field: 'invDate',
                    formatter: function (value, row, index) {
                        return changeDateFormat(value)
                    }
                },
                {title: "记录人", field: 'invTakePerson'},
                {
                    title: "记录时间", field: 'invCreateDate',
                    formatter: function (value, row, index) {
                        return changeDateFormat(value)
                    }
                },
                {
                    title: "操作", formatter: function (value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0);" onclick="uploading(' + js.jsonStringify(row) + ')" > 上传</a> ');
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0);" onclick="selectFapiaoList(' + js.jsonStringify(row) + ')"> 查看附件</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0);" onclick="delete333(' + js.jsonStringify(row) + ')"> 删除</a> ');
                        return actions.join('');
                    }
                }
            ]
        });

    });









    function delete333(row) {
        $.ajax({
            type: 'GET',
            url: ctx + "invoiceDelete?invId=" + row.invId,
            processData: false,
            contentType: false,
            // dataType : 'text',
            success: function (msg) {
                if (msg === "删除成功") {
                    js.modal.success(msg);
                    $("#bootstrap-table2").bootstrapTable('refresh');
                    js.modal.closeLoading();
                } else {
                    js.modal.warning(msg);
                }
            }
        });
    }

    /**
     * 打开 查看回款 模态框
     */
    function openSelectMoneyModal(row) {
        //设置输入框中各项的值
        $("#moneyForm-select").fillData(row);

        //添加 应收未收 框的值
        var ysws = timeCompare(row.singleReceivableNotReceivedMoney, row);
        $("#moneyForm-select [name='yingshouweishou']").val(ysws);

        //调整 预计回款时间 格式
        var rmiExpectDate = changeDateFormat(row.rmiExpectDate);
        $("#moneyForm-select [name='rmiExpectDate']").val(rmiExpectDate);

        //调整款项百分比
        $("#moneyForm-select [name='rmiExpectScale']").val(changeHundred(row.rmiExpectScale));

        if (row.rmiIsAll == 1) {
            $("#yswsDiv-select").hide();
            $("#mzjeDiv-select").hide();
            $("#hzjeDiv-select").hide();
        }

        js.modal.open("modal-select-money");

    }

    /**
     * 打开 添加发票 模态框
     */
    function openCreateInvoiceModal() {
        $("#modal-invoice-add [name='invConId']").val([[${info.conId}]])
        // $("#invConId").val([[${info.conId}]]);
        // alert($("#invConId").val())
        js.modal.open("modal-invoice-add");
    }

    /**
     * 打开 编辑回款 模态框
     */
    function openEditMoneyModal(row) {
        $("#moneyForm-edit").fillData(row);

        var ysws = timeCompare(row.singleReceivableNotReceivedMoney, row);
        $("#moneyForm-edit [name='yingshouweishou']").val(ysws);

        var rmiExpectDate = changeDateFormat(row.rmiExpectDate);
        $("#moneyForm-edit [name='rmiExpectDate']").val(rmiExpectDate);

        $("#moneyForm-select [name='rmiExpectScale']").val(changeHundred(row.rmiExpectScale));

        js.modal.open("modal-edit-money");
    }

    //款项修改保存
    function saveData1(row) {
        var yishou, mozhang, huaizhang, huikuantime, rmiMoneyType, rmiName;
        huikuantime = $("#moneyForm-edit [name='rmiExpectDate']").val();
        yishou = $("#moneyForm-edit [name='singleAlreadyMoney']").val();
        mozhang = $("#moneyForm-edit [name='singleRmiDebtsMoney']").val();
        huaizhang = $("#moneyForm-edit [name='singleRmiBadMoney']").val();
        rmiName = $("#moneyForm-edit [name='rmiName']").val();
        // 1预付款、2进度款、3发货款、4到货款、5调试款、6验收款、7质保金
        if (rmiName == "预付款") {
            rmiMoneyType = 1;
        } else if (rmiName == "进度款") {
            rmiMoneyType = 2;
        } else if (rmiName == "发货款") {
            rmiMoneyType = 3;
        } else if (rmiName == "到货款") {
            rmiMoneyType = 4;
        } else if (rmiName == "调试款") {
            rmiMoneyType = 5;
        } else if (rmiName == "验收款") {
            rmiMoneyType = 6;
        } else if (rmiName == "质保金") {
            rmiMoneyType = 7;
        }
        // alert(yishou+","+mozhang+","+huaizhang+","+huikuantime);
        $.ajax({
            type: 'GET',
            url: ctx + "updateRmiByConIdAndRmiMoneyType?conId=" + [[${info.conId}]] + "&rmiMoneyType=" + rmiMoneyType + "&yishou=" + yishou + "&mozhang=" + mozhang + "&huaizhang=" + huaizhang + "&huikuantime=" + huikuantime,
            processData: false,
            contentType: false,
            // dataType : 'text',
            success: function (msg) {
                if (msg === "修改成功") {
                    js.modal.success(msg);
                    //切换回页面
                    //location.href = ctx + 'kpEdit/contractInfo?conId=' + [[${info.conId}]] ;
                    $("#bootstrap-table1").bootstrapTable('refresh');
                } else {
                    js.modal.warning(msg);
                }
                //js.modal.closeLoading();
            }
        });

    }


    /**
     * 比较时间  应收未收 在 预计还款日期 之前 = 0     之后 =未收
     */
    function timeCompare(value, row) {
        var d1 = new Date(Date.parse(changeDateFormat(row.rmiExpectDate)));
        // alert(d1);
        // alert(timeNow);
        if (d1 > timeNow) {
            value = "0";
        }
        if (changeDateFormat(row.rmiExpectDate) === "") {
            return "0";
        }
        return value;
    }

    /**
     * 百分比转换 保留四位小数
     * @param value
     * @returns {string}
     */
    function changeHundred(value) {
        value = String(value).replace(/^(.*\..{4}).*$/, "$1");
        value = Number(value);
        // alert(value+"-------------------------"+value* 100 + "%");
        // return value * 100 + "%";
        return (Math.round(value * 10000) / 100.00 + "%");// 小数点后两位百分比
    }

    function changeDateFormat(value) {
        if (value === '' || value === undefined) {
            return "";
        }
        var myDate = new Date(value);
        //获取当前年
        var year = myDate.getFullYear();
        //获取当前月
        var month = myDate.getMonth() + 1;
        month = month < 10 ? "0" + month : month;
        //获取当前日
        var date = myDate.getDate();
        date = date < 10 ? "0" + date : date;
        var h = myDate.getHours();       //获取当前小时数(0-23)
        h = h < 10 ? "0" + h : h;
        var m = myDate.getMinutes();     //获取当前分钟数(0-59)
        m = m < 10 ? "0" + m : m;
        var s = myDate.getSeconds();
        s = s < 10 ? "0" + s : s;
        var time = year + '-' + month + "-" + date;
        if (time === "1900-01-01" || time === "1970-01-01") {
            return "";
        }
        return time;
    }


    /***
     * 上传附件点击
     * @param 发票id
     * */
    function uploading(row) {
        // alert(row.invId)   //发票表主键值
        var invid = row.invId
        $("#modal-import [name='invId']").val(invid);
        js.modal.open("modal-import")
    }


    /***
     * 查看附件清单
     * @param 发票id
     * */
    function selectFapiaoList(row) {
        $("#bootstrap-table3").bootstrapTable('destroy');
        // var invid = row.invId
        // alert(row.invId);
        loadTable3(row.invId);
        js.modal.open("modal-fujianlist-select")
    }

    function loadTable3(id) {
        // alert(id)
        /** 加载用户表格 */
        table3 = js.table.init({
            id: "bootstrap-table3",
            url: ctx + "annexListByInvId?invId=" + id,
            showColumns: false,
            showExport: false,
            pageSize: 300,
            pagination: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        var pageSize = table2.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table2.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {title: "文件名", field: 'fileId', visible: false},
                {title: "文件名", field: 'fileName'},
                {title: "文件备注", field: 'fileComment'},
                {title: "上传日期", field: 'fileUploadDate'},
                {title: "上传者姓名", field: 'userName'},
                {
                    title: "操作", formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="' + row.fileUrl + '" > 下载</a> ');   //onclick="download222(' + js.jsonStringify(row) + ')"
                        // actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0);" onclick="delete222(' + js.jsonStringify(row) + ')" > 删除</a> ');
                        return actions.join('');
                    }
                }
            ]
        });
    }


    //下载附件（失败了--拒绝访问）
    // function download222(row) {
    //     // alert("+++++++++++")
    //     $.ajax({
    //         type: 'GET',
    //         url: ctx + "annexDownLoad?fileId=" + row.fileId,
    //         processData: false,
    //         contentType: false,
    //         // dataType : 'text',
    //         success: function (msg) {
    //             if (msg === "下载成功") {
    //                 js.modal.success(msg);
    //                 //切换回页面
    //                 //location.href = ctx + 'kpEdit/contractInfo?conId=' + [[${info.conId}]] ;
    //                 // setTimeout(function () {
    //                 //     location.href = ctx + 'kpEdit/contractInfo?conId=' + [[${info.conId}]];
    //                 // }, 2000);
    //             } else {
    //                 js.modal.warning(msg);
    //             }
    //             //js.modal.closeLoading();
    //         }
    //     });
    // }

    //删除附件
    function delete222(row) {
        // alert("+++++++++++")
        $.ajax({
            type: 'GET',
            url: ctx + "annexDelete?fileId=" + row.fileId,
            processData: false,
            contentType: false,
            // dataType : 'text',
            success: function (msg) {
                if (msg === "删除成功") {
                    js.modal.success(msg);
                    $("#bootstrap-table3").bootstrapTable('refresh');
                    js.modal.closeLoading();
                } else {
                    js.modal.warning(msg);
                }
            }
        });
    }

    /**
     * 上传附件
     */
    $("#btn-import").on('click', function () {
        js.submit({
            url: ctx + "invoice/uploadFile",
            data: new FormData($("#importForm")[0]),
            async: true,
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    js.modal.closeLoading();
                    js.table.search(table2);
                } else {
                    js.modal.warning(result.msg);
                }
            }
        })
        js.modal.closeLoading();
    });

    /**
     * 添加发票
     */
    $("#btn-save3").on('click', function () {

        js.submit({
            url: ctx + "invoiceAdd",
            data: new FormData($("#invoiceForm-add")[0]),
            async: true,
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    $("#bootstrap-table2").bootstrapTable('refresh');
                    js.modal.closeLoading();
                } else {
                    js.modal.warning(result.msg);
                }
            }
        })
        js.modal.closeLoading();
    });


</script>




